#include <iostream>
#include <stack>
#include <map>

bool is_valid_brackets(const std::string& sequence) {
    std::stack<char> stack;
    std::map<char, char> brackets_map = {{')', '('}, {']', '['}, {'}', '{'}, {'>', '<'}};
    for (char bracket : sequence) {
        auto it = brackets_map.find(bracket);
        if (it != brackets_map.end()) {
            if (!stack.empty() && stack.top() == it->second) {
                stack.pop();
            } else {
                return false;
            }
        } else {
            stack.push(bracket);
        }
    }
    return stack.empty();
}

int main() {
    std::string bracket_sequence;
    std::cout << "Введите скобочную последовательность: ";
    std::cin >> bracket_sequence;
    bool result = is_valid_brackets(bracket_sequence);
    std::cout << (result ? "true" : "false") << std::endl;
    return 0;
}